package com.eshop.api;

public class EshopException extends RuntimeException
{
    private static final long serialVersionUID = -2470461654663264392L;
    private Integer errorCode;
    private String message;
    
    public EshopException() {
    }
    
    public EshopException(final String message) {
        super(message);
        this.message = message;
    }
    
    public EshopException(final Integer errorCode, final String message) {
        super(message);
        this.errorCode = errorCode;
        this.message = message;
    }
    
    public EshopException(final ApiCode apiCode) {
        super(apiCode.getMessage());
        this.errorCode = apiCode.getCode();
        this.message = apiCode.getMessage();
    }
    
    public EshopException(final String message, final Throwable cause) {
        super(message, cause);
    }
    
    public EshopException(final Throwable cause) {
        super(cause);
    }
    
    public Integer getErrorCode() {
        return this.errorCode;
    }
    
    @Override
    public String getMessage() {
        return this.message;
    }
    
    public void setErrorCode(final Integer errorCode) {
        this.errorCode = errorCode;
    }
    
    public void setMessage(final String message) {
        this.message = message;
    }
    
    @Override
    public String toString() {
        return "EshopException(errorCode=" + this.getErrorCode() + ", message=" + this.getMessage() + ")";
    }
    
    @Override
    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof EshopException)) {
            return false;
        }
        final EshopException other = (EshopException)o;
        if (!other.canEqual(this)) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        final Object this$errorCode = this.getErrorCode();
        final Object other$errorCode = other.getErrorCode();
        Label_0075: {
            if (this$errorCode == null) {
                if (other$errorCode == null) {
                    break Label_0075;
                }
            }
            else if (this$errorCode.equals(other$errorCode)) {
                break Label_0075;
            }
            return false;
        }
        final Object this$message = this.getMessage();
        final Object other$message = other.getMessage();
        if (this$message == null) {
            if (other$message == null) {
                return true;
            }
        }
        else if (this$message.equals(other$message)) {
            return true;
        }
        return false;
    }
    
    protected boolean canEqual(final Object other) {
        return other instanceof EshopException;
    }
    
    @Override
    public int hashCode() {
        final int PRIME = 59;
        int result = super.hashCode();
        final Object $errorCode = this.getErrorCode();
        result = result * 59 + (($errorCode == null) ? 43 : $errorCode.hashCode());
        final Object $message = this.getMessage();
        result = result * 59 + (($message == null) ? 43 : $message.hashCode());
        return result;
    }
}
